<?php
include_once("{$_SERVER['DOCUMENT_ROOT']}/CommonClasses/MySQLDAO.php");
include("MediaCollTypesBean.php");

class MediaCollTypesDAO extends MySQLDAO {
	protected function lookupSqlById($id) {
		switch($id) {
			case "SELECT":
				return "select id,name,active from media_coll_types where id = ?";
				break;
			case "INSERT":
				return "insert into media_coll_types (id,name,active) values (?,?,?)";
				break;
			case "UPDATE":
				return "update media_coll_types set id = ?,name = ?,active = ? where id = ?";
				break;
			case "DELETE":
				return "delete from media_coll_types where id = ?";
				break;
			default:
				return;
				break;
		}
	}

	protected function bindParameters($id,$paramBean) {
		switch($id) {
			case "SELECT":
				$params[0] = $this->bindInt($paramBean->getId());
				break;
			case "INSERT":
				$params[0] = $this->bindInt($paramBean->getId());
				$params[1] = $this->bindString($paramBean->getName());
				$params[2] = $this->bindString($paramBean->getActive());
				break;
			case "UPDATE":
				break;
			case "DELETE":
				break;
		}
		return $params;
	}

	protected function loadBean($id,$row,$rows) {
		$bean = new MediaCollTypesBean();
		switch($id) {
			case "SELECT":
				$bean->setId($row['id']);
				$bean->setName($row['name']);
				$bean->setActive($row['active']);
				break;
		}
		array_push($rows,$bean);
		return $rows;
	}

	protected function getDbPropertiesFile($file="") {
    	try {
			parent::getDbPropertiesFile();
        }
		catch(Exception $e) {
			print('<br><br><span style="color:red;">There was an error loading the properties file!!</span>');
	        exit();
        }
	}
}
?>
